﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace BrasilFramework.Comum.WPF.Utilitario
{
    public class Formatador : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if((value == null || (parameter == null || !(parameter is string)))) return value;
            
            if(parameter.ToString().ToLower().Equals("bool"))
                return (bool.Parse(value.ToString())) ? Mensagem.Sim : Mensagem.Nao;

            return string.Format(CultureInfo.CurrentCulture, parameter.ToString(), value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}